package org.inspursc.s0517.health.common.converter;

import org.inspursc.s0517.health.common.dto.SysRoleDTO;
import org.inspursc.s0517.health.common.entity.SysRole;
import org.inspursc.s0517.health.common.form.RoleForm;
import org.inspursc.s0517.health.common.vo.SysRoleVO;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;


public class RoleConverter2SysRoleDTO {

    public static SysRoleDTO converter(RoleForm roleForm) {
        SysRoleDTO role = new SysRoleDTO();
        BeanUtils.copyProperties(roleForm, role);
        return role;
    }

    public static SysRoleDTO converter(SysRole sysRole) {
        SysRoleDTO sysRoleDTO = new SysRoleDTO();
        BeanUtils.copyProperties(sysRole, sysRoleDTO);
        return sysRoleDTO;
    }

    public static SysRoleVO converterVO(SysRole sysRole) {
        SysRoleVO sysRoleVO = new SysRoleVO();
        BeanUtils.copyProperties(sysRole, sysRoleVO);
        return sysRoleVO;
    }

    public static SysRole converter(SysRoleDTO sysRoleDTO) {
        SysRole sysRole = new SysRole();
        BeanUtils.copyProperties(sysRoleDTO, sysRole);
        return sysRole;
    }

    public static List<SysRoleDTO> converter(List<SysRole> sysRoleList) {
        return sysRoleList.stream().map(e -> converter(e)).collect(Collectors.toList());
    }
}
